package com.eastfair.point.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.eastfair.cache.repository.CachePlusOps;
import com.eastfair.core.rocketmq.MqCacheKeyBuilder;
import com.eastfair.mq.model.MySimpleMessage;
import com.eastfair.point.point.StoreTransaction;
import com.eastfair.point.service.OrderService;
import com.eastfair.point.service.StoreService;
import com.eastfair.transaction.mq.service.AbstractBaseTransactionService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQLocalTransactionState;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 广播处理事件
 *
 * @author ligang
 * @date 2021-08-10
 */
@Slf4j
@Service
public class StoreServiceImpl<T> extends AbstractBaseTransactionService<StoreTransaction> implements StoreService<StoreTransaction> {

    @Autowired
    private CachePlusOps cachePlusOps;


    @Override
    public RocketMQLocalTransactionState executeCommit(StoreTransaction storeTransaction) {
        log.info("Store 本地执行 "+JSON.toJSONString(storeTransaction));
        return RocketMQLocalTransactionState.COMMIT;
    }

    @Override
    public RocketMQLocalTransactionState backTransaction(StoreTransaction storeTransaction) {
        log.info("Store 执行回查 "+JSON.toJSONString(storeTransaction));
        return RocketMQLocalTransactionState.COMMIT;
    }

    @Override
    public void executeBusinOfReceiveMsg(StoreTransaction storeTransaction) {
        //收到mq消息，执行库存功能，然后调用积分服务
        sendQueueMessage(storeTransaction);
    }
}
